#ifndef THREAD_H
#define THREAD_H

#include "pthread.h"
#include "string"

using namespace std;

//--------------------------------------------------
// T H R E A D
//--------------------------------------------------
class Thread {
public:
	// Thread priorities
	enum ThreadPriority {
		PRIORITY_LOW = 0,
		PRIORITY_BELOW_NORMAL = 1,
		PRIORITY_NORMAL = 2,
	/*		PRIORITY_ABOVE_NORMAL = THREAD_PRIORITY_ABOVE_NORMAL,
	 PRIORITY_HIGH = THREAD_PRIORITY_HIGHEST,*/
	};
	Thread(ThreadPriority pri = Thread::PRIORITY_NORMAL, string _name = "");
	~Thread();
	bool setPriority(ThreadPriority pri);
	ThreadPriority getPriority();
	string getName();
	void start();
	virtual void run() = 0;
protected:
	ThreadPriority priority;
	string name;

	pthread_t handle;

	static void* threadMapper(void* p) {
		((Thread*) p)->run();
	}
};

#endif
